<template>
  <!-- 底部部分 => list有数据的时候，才展示  list.length > 0 -->
  <footer  class="footer" v-if="list.length>0">
    <span class="todo-count"><strong>{{num}}</strong>剩余</span>
    <ul class="filters">
      <li>
        <a  href="#/"
        :class="{selected:stauts ==='all'}" 
        @click="$emit('stauts-event','all')">全部</a>
      </li>
      <li>
        <a  href="#/active" 
        :class="{selected:stauts ==='undone'}"  
        @click="$emit('stauts-event','undone')">进行中</a>
      </li>
      <li>
        <a  href="#/completed" 
        :class="{selected:stauts ==='done'}"  
        @click="$emit('stauts-event','done')">已完成</a>
      </li>
    </ul>
    <!-- 有已完成的任务，才需要显示这个按钮 -->
    <button  class="clear-completed" @click="$emit('clear-All')">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props:{
    list:{
      type:Array,
      required:true,
    },
    stauts:{
      type:String,
      required:true,
      // 自定义验证函数
      validator(value){
        // 这个值必须匹配下列字符串中的一个
       return['all','done','undone'].includes(value)
      }
    }

    },
    computed:{
      num(){
        return this.list.filter((item)=>item.done ===false).length
      }
    }
  }
  

</script>

<style></style>
